package com.ssy.lingxi.order.controller.web;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.request.OrderDayParamVO;
import com.ssy.lingxi.order.model.vo.basic.request.OrderDeliveryTimeVO;
import com.ssy.lingxi.order.model.vo.basic.request.OrderShopIdVO;
import com.ssy.lingxi.order.model.vo.basic.response.OrderDayVO;
import com.ssy.lingxi.order.model.vo.basic.response.OrderDeliveryDateVO;
import com.ssy.lingxi.order.model.vo.basic.response.OrderTimeVO;
import com.ssy.lingxi.order.service.web.IOrderTimeParamService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 系统能力 - 订单时间参数配置相关接口
 * @author wyx
 * @version 2.0.0
 * @date 2021-10-13
 */
@RestController
@RequestMapping("/order/param")
public class OrderTimeParamController {
    @Resource
    private IOrderTimeParamService orderTimeParamService;


    /**
     * 查看自动确认收货时间
     * @param headers HttpHeaders信息
     * @return 查询结果
     */
    @RequestMapping(value = "/get/receiver/day", method = RequestMethod.GET)
    public Wrapper<List<OrderDayVO>> getReceiverDay(@RequestHeader HttpHeaders headers) {
        return orderTimeParamService.getReceiverDay(headers);
    }

    /**
     * 添加/修改自动确认收货时间
     * @param headers HttpHeaders信息
     * @param updateVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/update/receiver/day", method = RequestMethod.POST)
    public Wrapper<Void> updateReceiverDay(@RequestHeader HttpHeaders headers, @RequestBody @Valid List<OrderDayParamVO> updateVO) {
        return orderTimeParamService.updateReceiverDay(headers, updateVO);
    }

    /**
     * 查看送货预约时长
     * @param headers HttpHeaders信息
     * @return 查询结果
     */
    @RequestMapping(value = "/get/appointment/day", method = RequestMethod.GET)
    public Wrapper<List<OrderDayVO>> getAppointmentDay(@RequestHeader HttpHeaders headers) {
        return orderTimeParamService.getAppointmentDay(headers);
    }

    /**
     * 添加/修改送货预约时长
     * @param headers HttpHeaders信息
     * @param updateVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/update/appointment/day", method = RequestMethod.POST)
    public Wrapper<Void> updateAppointmentDay(@RequestHeader HttpHeaders headers, @RequestBody @Valid List<OrderDayParamVO> updateVO) {
        return orderTimeParamService.updateAppointmentDay(headers, updateVO);
    }

    /**
     * 查看配置配送时间段
     * @param headers HttpHeaders信息
     * @return 查询结果
     */
    @RequestMapping(value = "/get/delivery/time", method = RequestMethod.GET)
    public Wrapper<List<OrderTimeVO>> getDeliveryTime(@RequestHeader HttpHeaders headers) {
        return orderTimeParamService.getDeliveryTime(headers);
    }

    /**
     * 添加/修改配置配送时间段
     * @param headers HttpHeaders信息
     * @param updateVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/update/delivery/time", method = RequestMethod.POST)
    public Wrapper<Void> updateDeliveryTime(@RequestHeader HttpHeaders headers, @RequestBody @Valid List<OrderDeliveryTimeVO> updateVO) {
        return orderTimeParamService.updateDeliveryTime(headers, updateVO);
    }

    /**
     * 根据会员信息和商城id获取预约时长和配置配送时间段
     * @param headers HttpHeaders信息
     * @param shopIdVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/find/delivery/date", method = RequestMethod.GET)
    public Wrapper<OrderDeliveryDateVO> findDeliveryDate(@RequestHeader HttpHeaders headers, @Valid OrderShopIdVO shopIdVO) {
        return orderTimeParamService.findDeliveryDate(headers, shopIdVO);
    }
}

